package m.jclecai.com.utils;

public class SumUtil {
	
	/****
	 * 
	* @Title: sum 
	* @Description: 
	* @param @param start 开始
	* @param @param n  几窜
	* @param @param array
	* @param @param length=length-1
	* @param @return   
	* @return double    
	* @throws
	 */
   public static int sum(int start,int n,int[] array,int length){
		int sum = 0;
		int end=start-1+n;
	    end=end>=length?length-1:end;
		for(int i=start;i<=end;i++){
			sum+=array[i];
		}
		return sum;
	}
	
   /**
    * @category 串数计算（修正版）
    * @param n
    * @param array
    * @return
    */
	public static int sn(int n,int[] array){
		int s=0;
		int length=array.length;
		for(int i=0;i<length-1;i++){
			s+=array[i]*sum(i+1,n,array,length);
		}
		return s;
	}

}
